/*
 * Copyright 2018-present KunMinX
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.nsgf.library.ui.adapter;

import android.content.Context;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.kunminx.binding_recyclerview.adapter.SimpleDataBindingAdapter;
import com.nsgf.library.R;
import com.nsgf.library.data.bean.WorkOrderDetailBean;
import com.nsgf.library.databinding.ItemManagerWorkOrderItemBinding;
import com.nsgf.library.photopicker.widget.MultiPickResultView;
import com.nsgf.library.utils.StringUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Create by GC at 24/10/29
 */
public class ManagerDamTaskRecordListAdapter extends SimpleDataBindingAdapter<WorkOrderDetailBean.DataBean.PositionVOSBean.ItemsBean, ItemManagerWorkOrderItemBinding> {

    public ManagerDamTaskRecordListAdapter(Context context) {
        super(context, R.layout.item_manager_work_order_item, DiffUtils.getInstance().getmWorkOrderDetailTaskItemCallback());
    }

    public List<ItemManagerWorkOrderItemBinding> itemBindings = new ArrayList<>();

    @Override
    protected void onBindItem(ItemManagerWorkOrderItemBinding binding,
                              WorkOrderDetailBean.DataBean.PositionVOSBean.ItemsBean item,
                              RecyclerView.ViewHolder holder) {
        binding.setAlbum(item);
        itemBindings.add(binding);
        binding.itemNsgfSwitch.setVisibility(View.GONE);
        binding.etNsgfManagerAbnormalDescribe.setEnabled(false);

        if ("txt".equals(item.getResultType())){
            binding.tvItemManagerItemValue.setVisibility(View.GONE);
        }else {

            binding.tvItemManagerItemValue.setVisibility(View.VISIBLE);
        }
        if (StringUtil.isEmpty(item.getAbnormalDescribe())) {
            item.setViewGone(View.GONE);
        } else {
            item.setViewGone(View.VISIBLE);
            binding.multiPickResultView.removeAllViews();
            binding.multiPickResultView.init(mContext, MultiPickResultView.ACTION_ONLY_SHOW, (ArrayList<WorkOrderDetailBean.FileDto>) item.getPhotos(), 3, binding.multiPickResultView.getId());
        }

    }

}
